package cn.edu.scau.dao;

import cn.edu.scau.entity.NursingLevel;

import java.util.List;

import org.apache.ibatis.annotations.CacheNamespace;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Result;
import org.apache.ibatis.annotations.Results;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;


@Mapper
@CacheNamespace
public interface NursingLevelMapper {
	/**
	  * 根据护理等级编号删除护理级别信息
	 * @param nursinglevelid
	 * @return
	 */
    @Delete({
        "delete from nursinglevel",
        "where nursingLevelID = #{nursinglevelid,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Integer nursinglevelid);

    /**
         * 全参新增护理等级信息：不考虑为null情况
     * @param record
     * @return
     */
    @Insert({
        "insert into nursinglevel (nursingLevelID, nursingLevelLevel, ",
        "nursingLevelConfigurationContent)",
        "values (#{nursinglevelid,jdbcType=INTEGER}, #{nursinglevellevel,jdbcType=VARCHAR}, ",
        "#{nursinglevelconfigurationcontent,jdbcType=VARCHAR})"
    })
    int insert(NursingLevel record);

    /**
         * 全参新增护理等级信息：考虑为null情况，如果为空，不向数据库插入数据
     * @param record
     * @return
     */
    @InsertProvider(type=NursingLevelSqlProvider.class, method="insertSelective")
    int insertSelective(NursingLevel record);

    /**
         *  根据护理等级编号查询部门信息
     * @param nursinglevelid
     * @return
     */
    @Select({
        "select",
        "nursingLevelID, nursingLevelLevel, nursingLevelConfigurationContent",
        "from nursinglevel",
        "where nursingLevelID = #{nursinglevelid,jdbcType=INTEGER}"
    })
    @Results({
        @Result(column="nursingLevelID", property="nursinglevelid", jdbcType=JdbcType.INTEGER, id=true),
        @Result(column="nursingLevelLevel", property="nursinglevellevel", jdbcType=JdbcType.VARCHAR),
        @Result(column="nursingLevelConfigurationContent", property="nursinglevelconfigurationcontent", jdbcType=JdbcType.VARCHAR)
    })
    NursingLevel selectByPrimaryKey(Integer nursinglevelid);

    /**
         * 查询所有护理等级信息
     * @return
     */
	@Select({
	    "select",
	    "nursingLevelID, nursingLevelLevel, nursingLevelConfigurationContent",
	    "from nursinglevel"
	})
	List<NursingLevel> selectAll();
	
	/**
	  * 根据护理具体等级模糊查询
	 * @param nursinglevellevel
	 * @return
	 */
	@SelectProvider(type = NursingLevelSqlProvider.class,method = "findByNursinglevellevel")
	List<NursingLevel> findByNursinglevellevel(@Param("nursinglevellevel")String nursinglevellevel);
    
    /**
         * 全参修改护理等级信息：考虑为null情况，如果为空，不会修改数据库中内容
     * @param record
     * @return
     */
    @UpdateProvider(type=NursingLevelSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(NursingLevel record);

    /**
         * 全参修改护理等级信息：不考虑为null情况，如果为空，数据库中对应内容将重置为null
     * @param record
     * @return
     */
    @Update({
        "update nursinglevel",
        "set nursingLevelLevel = #{nursinglevellevel,jdbcType=VARCHAR},",
          "nursingLevelConfigurationContent = #{nursinglevelconfigurationcontent,jdbcType=VARCHAR}",
        "where nursingLevelID = #{nursinglevelid,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(NursingLevel record);
}